home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
smaltalk
/
stv.lha
/
STV
/
ISA
/
artifact
/
notifier.cls
< prev
next >
Wrap
Text File
|
1993-07-23
|
4KB
|
138 lines
" Notifier Window by Tom Wrensch & Gene Korienek
The Notifier is a window that will pop up with
some text in it. Not a big deal, but its nice
for when a Menu message: won't do the trick
because theres too much information to put in
one line.
The advantage of the notifier over using the
edit message in string is that it can take text
as either a string with embedded LF or CR's or
as an array of strings. Also the notifier will
size itself appropriatly to the text it contains."
There are two ways of opening a notifier:
Notifier new openOn: SomeBigString.
Notifier new openBeepOn: SomeBigString.
The only difference is that the second one will beep
as the notifier is opening."!
Object subclass: #Notifier
instanceVariableNames:
'pane msg '
classVariableNames: ''
poolDictionaries: '' !
!Notifier class methods ! !
!Notifier methods !
accept: aString from: aDispatcher
"This doesn't make sense for this application,
so ignore it"
^true!
activateWindow
"Since notifiers are usualy activated only once,
update the pane so it displays the text of the
message instead of an empty string."
pane update!
initWindowSize
"Answer the initial window extent. This is sized
based on the messages maximum line length and
number of lines, and of course the font used
to display the message."
| x y |
" Get the X and Y sizes for the window "
x := (SysFont stringWidth: 'Notifier') + 6 +
(SysFont height * 3).
msg do: [:str |
x := x max: (TextFont stringWidth: str)].
x := x + 6.
y := SysFont height + 11 +
(TextFont height * msg size).
" If the window is to big, make it half screen
and leave room for the scroll bar"
y > Display extent y ifTrue: [
y := Display extent y // 2.
x := x + 18].
^x @ y!
makeLines: aMessage
"Private - Answer the message as an array of lines."
| list stream |
(aMessage isKindOf: String)
ifTrue: [
list := OrderedCollection new.
stream := aMessage asStream.
[stream atEnd] whileFalse: [
list addLast: stream nextLine]]
ifFalse: [
(aMessage isKindOf: Collection)
ifTrue: [list := aMessage]
ifFalse: [list := Array with: '']].
^list asArray!
makeTextPane
"Private - Create and answer the text
pane for the window."
^TextPane new
model: self;
name: #text;
change: #accept:from:;
yourself!
makeTopPane
"Private - Create and answer the
top pane for this window applicaiton."
^TopPane new
model: self;
label: 'Notifier';
minimumSize: 100@50;
rightIcons: #(collapse);
foreColor: 0;
backColor: 15;
yourself.!
openBeepOn: aMessage
"Open up the suggestor window and beep as
it opens to let the user know about it."
self openOn: aMessage withBeep: true!
openOn: aMessage
"Open up the suggestor window without beeping."
self openOn: aMessage withBeep: false!
openOn: aMessage withBeep: beepFlag
"Open up the suggestor window with the text
in aMessage and a beep if beepFlag is true."
| aTopPane |
msg := self makeLines: aMessage.
aTopPane := self makeTopPane.
pane := self makeTextPane.
aTopPane addSubpane: pane.
beepFlag == true ifTrue: [Terminal bell].
aTopPane dispatcher open scheduleWindow!
text
"Answer the text string to be displayed."
| stream |
stream := (String new: 0) asStream.
msg do: [:str |
stream nextPutAll: str; cr].
^stream contents! !